#{extends '/template/main.html' /}
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">全部角色</h3>

        <div class="panel-options">
            <a href="/power/admin/AdminRoleCtrl/loadRoleDetail">
                <button class="btn btn-success btn-icon">
                    <i class="fa-plus-square-o"></i>
                    <span>新建角色</span>
                </button>
            </a>
        </div>
    </div>
    <div class="panel-body">
        <form method="get" id="searchForm" action="/power/admin/AdminRoleCtrl/loadRoleList/${pageNumber}">
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="code" id="code" class="form-control" style="width:150px" placeholder="角色编号" value="${code}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="name" id="name" class="form-control" style="width:150px" placeholder="角色名称" value="${name}">
            </div>

        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                *{<th class="no-sorting">}*
                    *{<input type="checkbox" class="cbr">}*
                *{</th>}*
                <th>角色编号</th>
                <th>角色名称</th>
                <th>状态</th>
                <th>备注</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="middle-align">
            #{paginate.list items:resultPage , as :'adminRole'}
            <tr>
                *{<td>}*
                    *{<input type="checkbox" class="cbr">}*
                *{</td>}*
                <td>${adminRole?.code}</td>
                <td>${adminRole?.name}</td>
                <td>${adminRole?.status}</td>
                <td>${adminRole?.remark}</td>

                <td>
                    <a href="/power/admin/AdminRoleCtrl/loadRoleDetail/${adminRole?.id}/${pageNumber}" class="btn btn-secondary btn-sm btn-icon icon-left">
                        编辑
                    </a>

                    <a href="#" id="idBtnAvailable" onclick="disablaComfim(${adminRole?.id} ,1);" class="btn btn-success btn-sm btn-icon icon-left">
                        启用
                    </a>
                    <a href="#" id="idBtnFreeze" onclick="disablaComfim(${adminRole?.id} , 2);" class="btn btn-danger btn-sm btn-icon icon-left">
                        禁用
                    </a>


                </td>
            </tr>
            #{/paginate.list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>



<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">

<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

<script type="text/javascript" src="/public/laypage/laypage.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
            saveSuccess(msg);
        }

        // 分页
        laypage({
            cont: $('#layerPage'), //容器。值支持id名、原生dom对象，jquery对象,
            pages: '${resultPage?.pageCount}', //总页数
            skin: 'yahei',
            skip: true, //是否开启跳页
            curr:'${pageNumber}',
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/power/admin/AdminRoleCtrl/loadRoleList/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/power/admin/AdminRoleCtrl/loadRoleList/1");
            $('#searchForm').submit();
        })

    });

    //点击确认禁用 之后执行的方法
    function sureDisableConfirm() {
        var id = $('#operateId').val() ;
        var operateType = $('#operateType').val();
        var url = '/power/admin/AdminRoleCtrl/availableRole/'+id+'/${pageNumber}' ;
        if(operateType == 2)
            url = '/power/admin/AdminRoleCtrl/freezeRole/' + id + '/${pageNumber}';

        document.location.href = url ;
    }


</script>


